package com.uzai.console.web.user;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.user.mini.MiniUserIdDto;
import com.uzai.console.dto.user.mini.MiniUserInfoUpdateDto;
import com.uzai.console.dto.user.mini.MiniUserQuery;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.user.MiniUserService;
import com.uzai.console.vo.user.mini.MiniUserInfoVo;
import com.uzai.console.vo.user.mini.MiniUserPageVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author liuqi
 * @date 2021年08月25日 20:15
 */
@Api(value = "小程序会员", tags = "用户管理|小程序会员")
@ApiSort(15)
@RestController
public class MiniUserContoller extends BaseController {

    @Autowired
    private MiniUserService miniUserService;

    @ApiOperation(value = "分页查询小程序会员列表", notes = "分页查询小程序会员列表", response = MiniUserPageVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/miniUser/findMiniUserList")
    public Object findMiniUserList(@RequestBody MiniUserQuery miniUserQuery) {
        return miniUserService.findMiniUserList(miniUserQuery);
    }

    @ApiOperation(value = "查询小程序会员详情", notes = "查询小程序会员详情", response = MiniUserInfoVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/miniUser/findMiniUserInfo")
    public Object findMiniUserInfo(@RequestBody MiniUserIdDto miniUserIdDto) {
        return miniUserService.findMiniUserInfo(miniUserIdDto);
    }

    @SystemLogType(model = SystemModelEnum.MiniUser, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "单个修改小程序会员详情", notes = "单个修改小程序会员详情")
    @ApiOperationSupport(order = 3)
    @PostMapping("/miniUser/updateMiniUser")
    public Object updateMiniUser(@RequestBody MiniUserInfoUpdateDto infoUpdateDto) {
        miniUserService.updateMiniUserInfo(infoUpdateDto);
        return true;
    }

}
